import React, { Component } from 'react'
import {withRouter} from 'react-router-dom';
//withRouter 可以加工一般组件，让一般具备路由组件所特有的api
//withRouter 返回值是一个新组件
 class Header extends Component {
  back=()=>{
    this.props.history.goBack()
  }
  forward=()=>{
    this.props.history.goForward()
  }
  go=()=>{
    this.props.history.go(-1)
  }
  render() {
    console.log(this.props)
    return (
      <div>
        <h1>www</h1>
        <button onClick={this.back}>回退</button>
        <button onClick={this.forward}>前进</button>
        <button onClick={this.go}>前进</button>
      </div>
    )
  }
}
export default withRouter(Header)